package com.shanzhu.beadhouse.dao.mapper;

import com.shanzhu.beadhouse.entity.po.Staff;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shanzhu.beadhouse.entity.query.PageFreeStaffQuery;
import com.shanzhu.beadhouse.entity.query.PageStaffByKeyQuery;
import com.shanzhu.beadhouse.entity.vo.PageStaffByKeyVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 员工表 Mapper 接口
 * </p>
 *
  * @author: pjy
 
 */
public interface StaffMapper extends BaseMapper<Staff> {
    /**
     * 根据关键字查询员工列表
     *
     * @param keyQuery
     * @return
     */
    List<PageStaffByKeyVo> listStaffByKey(@Param("keyQuery") PageStaffByKeyQuery keyQuery);

    @Select("SELECT s.id,\n" +
            "        s.`name`,\n" +
            "        r.`name` AS role_name,\n" +
            "        s.id_num,\n" +
            "        s.sex,\n" +
            "        s.phone,\n" +
            "        s.email,\n" +
            "        s.leave_flag\n" +
            "FROM staff s\n" +
            "LEFT JOIN staff_elder se ON s.id=se.staff_id AND se.del_flag='N'\n" +
            "LEFT JOIN role r ON r.id = s.role_id\n" +
            "WHERE r.name='健康管家' AND se.id IS NULL " +
            "AND s.sex=#{sex}")
    List<PageStaffByKeyVo> listFreeStaffByKey(String sex);
}
